<?php 
defined('_JEXEC') or die;
?>
<div class="mod-module">
	<div class="mod-sx">
		
		<h1 class="xs">Tin tức</h1>
		<ul>
			<?php foreach($items as $k => $v):?>
			<li><h2><a href="<?php echo JRoute::_('index.php?option=com_content&view=category&id='.$v->id) ?>"><?php echo $v->title;?></a></h2>
			<?php 
			$show_sub = false;
			$view = JRequest::getVar('view','');
			
			
			if($view == 'category')
			{
				$id = JRequest::getInt('id',0);
				
			}
			else
			{
				$id = JRequest::getInt('catid',0);
			}
			
			if($id == $v->id){
				$show_sub = true;
			}
			else
			{
				foreach($v->sub as $k1 => $v1)
				{
					if($v1->id == $id)
					{
						$show_sub = true;
						break;
					}
				}
			}
			
			
			?>
			<?php if($show_sub && $v->sub):?>
			<ul>
				<?php foreach($v->sub as $k_sub => $v_sub):?>
				<li><h2><a href="<?php echo JRoute::_('index.php?option=com_content&view=category&id='.$v_sub->id) ?>"><?php echo $v_sub->title;?></a></h2></li>
				<?php endforeach;?>
			</ul>
			<?php endif;?>
			</li>
			<?php endforeach;?>
		</ul>
		
	</div>
</div>